Skip to content

Handle GitHub comment runs without Socket ignore commands - #464

Merged
lelia merged 7 commits into
mainfrom
fix/issue-comment-keyerror
Nov 24, 2026
Merged

lelia merged 7 commits into
mainfrom
fix/issue-comment-keyerror

Conversation

@dc-larsen

@dc-larsen David Larsen (dc-larsen) commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

GitHub issue_comment runs could raise KeyError: 'ignore' when a pull request had a Socket security comment and the fetched thread contained no ignore commands the CLI would honor. The same error occurred when the write-access check rejected the only ignore command.

The GitHub and GitLab adapters now leave the security comment alone when there are no ignore commands to process. The shared parser handles a missing ignore list. The CI guide recommends using a dedicated pull_request scan job as the required check.

Verification

  • CLI tests use the GitHub adapter with mocked HTTP responses. They cover ordinary comments, an ignore command rejected for read-only access, targeted ignores, ignore-all, malformed commands, and --disable-ignore. The ordinary and denied cases run with --strict-blocking and check for no scan, comment update, reaction, or ignore telemetry.
  • The original fix was also checked in a GitHub test repository. Ordinary comments left the security comment untouched. Targeted ignores and ignore-all updated it.
  • Unit and core tests, Ruff, lockfile validation, and the 2.14.0 package build passed.

Release

Ships in 2.14.0. Merge order: #461 → #462 → #460 → #464 → #465 → #463. Merged together in that order on main at #459, the six pass the full test suite and ruff check. main requires branches to be up to date, so update each PR from main after the previous merge. CHANGELOG.md will conflict each time: combine the bullets under the existing ## 2.14.0 subsections (Upgrade notes, Changed, Fixed, Documentation) by hand rather than taking either side.

This is 4 of 6. Only CHANGELOG.md conflicts.

Public Changelog

GitHub pull request comment runs exit 0 and leave the Socket security comment unchanged when there are no Socket ignore commands to process.


Fixes: CE-517

An issue_comment run on a pull request that already has a Socket security
comment crashed with KeyError: 'ignore' and exited 3 unless the pull request
also had an honored @SocketSecurity ignore command. check_for_socket_comments
only adds the "ignore" key when such a command exists, but
remove_comment_alerts called process_security_comment whenever the security
comment existed, and get_ignore_options indexed comments["ignore"] directly.
Any ordinary comment, or an ignore command from someone without write
access, failed the job.

remove_comment_alerts (GitHub and GitLab) now returns early and leaves the
security comment untouched when there are no ignore commands, and
get_ignore_options treats a missing key as no commands. Ignore, ignore-all
and --disable-ignore behave as before.
@lelia lelia changed the title Stop failing issue_comment runs that have no ignore command Handle GitHub comment runs without Socket ignore commands Nov 24, 2026
@lelia
lelia marked this pull request as ready for review November 24, 2026 02:53
@lelia

lelia commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

bugbot run

@lelia
lelia requested a review from a team as a code owner November 24, 2026 02:53
@cursor

cursor Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Scoped to SCM comment-event handling when no ignore commands apply; merge-gating scans are unchanged if CI uses a dedicated pull_request job.

Overview
Releases 2.14.0 (bumps pinned socketdev to 3.6.4). The main behavior change is for GitHub/GitLab issue_comment runs: when the PR has no actionable @SocketSecurity ignore commands, the CLI exits 0, logs that nothing was processed, and does not rewrite the security comment or post reactions.

GitHub and GitLab remove_comment_alerts now return immediately if the parsed comment map has no ignore list. Comments.get_ignore_options uses comments.get("ignore", []) so missing ignore no longer raises KeyError (including when the only ignore was rejected for read-only access).

docs/ci-cd.md notes this no-op behavior and recommends a separate pull_request job for merge gates. Unit tests cover ordinary comments, denied ignores, valid ignores, ignore-all, malformed commands, and --disable-ignore.

Reviewed by Cursor Bugbot for commit bbe5397. Configure here.

@lelia
lelia temporarily deployed to socket-firewall November 24, 2026 02:53 — with GitHub Actions Inactive

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit bbe5397. Configure here.

# Conflicts:
#	CHANGELOG.md
@lelia
lelia merged commit ef54e69 into main Nov 24, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants